package com.djsearch.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.djsearch.R;
import com.djsearch.adapter.JingdianAdapter.ViewHolder;
import com.djsearch.bean.ForPurchase;

public class SortPopuWindowAdapter extends BaseAdapter {
	

	private Context mContext;
	private List<String> sortList;

	public SortPopuWindowAdapter(Context context,List<String> sortList) {
		mContext = context;
		this.sortList = sortList;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return sortList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return sortList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public void refreshData(List<String> list) {
		sortList = list;
		notifyDataSetChanged();
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub

		if (convertView == null) {
			LayoutInflater layoutInflater = ((Activity) mContext)
					.getLayoutInflater();
			convertView = layoutInflater.inflate(R.layout.city_check_list_itme, null);
			convertView.setTag(convertView);
		} else {
			convertView = (View) convertView.getTag();
		}
		TextView textView = (TextView) convertView.findViewById(R.id.cityName); 
	    textView.setText(sortList.get(position));
		return convertView;
	}



}
